<?php
(!defined('IN_TOA') || !defined('IN_ADMIN')) && exit('Access Denied!');
/*
	[天生创想] (C)2008-2011 515158 Inc.
	This is NOT a freeware, use is subject to license terms
    URL:http://www.515158.com/
*/
get_config_keytable("bbs_");

empty($do) && $do = 'list';
if ($do == 'list') {
	//列表信息 
	$wheresql = '';
	$page = max(1, getGP('page','G','int'));
	$pagesize = 20;
	$offset = ($page - 1) * $pagesize;
	$url = 'admin.php?ac=index&fileurl=bbs';
	if ($bbstype = getGP('bbstype','G')) {
	$type_bbsclass = $db->fetch_one_array("SELECT * FROM ".DB_TABLEPRE."bbsclass  WHERE classadmin like '%".GET_INC_USER_NAME($_USER->id)."%'");
	if($type_bbsclass["classadmin"]!=''){
		$wheresql .= " AND type = '1'";
		$url .= '&bbstype='.$bbstype;
		}else{
		prompt('对不起，你没有权限执行本操作！');
		}	
	}else{
	$wheresql .= " AND (type = '2' or type='3')";
	}
	if ($bbsclass = getGP('bbsclass','G')) {
		$wheresql .= " AND bbsclass = '".$bbsclass."'";
		$url .= '&bbsclass='.$bbsclass;	
	}
	$num = $db->result("SELECT COUNT(*) AS num FROM ".DB_TABLEPRE."bbs WHERE 1 $wheresql ORDER BY type desc,enddate desc,issuedate desc");
     $sql = "SELECT * FROM ".DB_TABLEPRE."bbs WHERE 1 $wheresql ORDER BY type desc,enddate desc,issuedate desc LIMIT $offset, $pagesize";
	$result = $db->fetch_all($sql);

	include_once('template/index.php');

} elseif ($do == '删 除') {

	$idarr = getGP('id','P','array');
	foreach ($idarr as $id) {
	$db->query("DELETE FROM ".DB_TABLEPRE."bbs WHERE id = '$id'");
	$db->query("DELETE FROM ".DB_TABLEPRE."bbs_log WHERE bbsid = '$id'");
	$content=$id;
	$title='删除贴子';
	get_oa_log_dbadd($id,$content,$title,30,$_USER->id);	
	}
	goto_page('admin.php?ac=index&fileurl=bbs');

} elseif ($do == 'keys') {
get_config_keytable("bbs_key");
    $id=$_GET["id"];
	$bbs = array(
		'type' => 2
	);
	update_db('bbs',$bbs, array('id' => $id));
	goto_page('admin.php?ac=index&fileurl=bbs&bbstype=1');

} elseif ($do == '置 顶') {
 get_config_keytable("bbs_type_");
	$idarr = getGP('id','P','array');
	$bbs = array(
		'type' => 3
	);
	foreach ($idarr as $id) {
	update_db('bbs',$bbs, array('id' => $id));
	}
	goto_page('admin.php?ac=index&fileurl=bbs');

} 


?>